<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Staff extends CI_Controller 
{	
	function __construct()
	{
		parent::__construct();
		$this->load->model('model_staff');
	}

	function index()
	{
		$data['data']=$this->model_staff->tampilData();
		$this->load->view("staff_view",$data);
	}

	function tambah()
	{
		$data = array(
			'nip' => $this->input->post('nip'), 
			'nama' => $this->input->post('nama'), 
			'hp' => $this->input->post('hp')
		);
		$this->model_staff->tambah($data);
		//redirect('master_data/data/1');
		$this->load->view('staff_view');
	}

	function edit()
	{
		$nip = $this->uri->segment(3);
		$data['data'] = $this->model_staff->per_id($nip);
		$this->load->view('staff_view',$data);
	}

	function update()
	{
		$nip = $this->input->post('nip');
		$data = array(			
			'nama' => $this->input->post('nama'), 
			'hp' => $this->input->post('hp')
		);
		$this->model_staff->update($nip,$data);
		//redirect('master_data/data/1');
		//$this->load->view('staff_view');
		redirect('staff');
	}

	function hapus()
	{
		$nip = $this->uri->segment(3);
		$this->model_staff->hapus($nip);		
		//redirect('master_data/data/1');
		redirect('staff');
	}
}

?>